package cn.com.pajx.pajx_smart_platform.ui.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Window;
import android.widget.TextView;

import cn.com.pajx.pajx_smart_platform.R;


/**
 * 自定义加载进度对话框
 * Created by ruancw on 2023/04/03.
 */

public class LoadingDialog extends Dialog {
    private final TextView tvMessage;

    public LoadingDialog(Context context) {
        super(context);
        setContentView(R.layout.loading_progress_layout);
        ///设置背景透明，不然会出现白色直角问题
        Window window = getWindow();
        if (window != null) {
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        }
        setCanceledOnTouchOutside(false);
        tvMessage = findViewById(R.id.tv_message);
    }

    /**
     * 为加载进度个对话框设置不同的提示消息
     *
     * @param message 给用户展示的提示信息
     * @return build模式设计，可以链式调用
     */
    public LoadingDialog setMessage(String message) {
        tvMessage.setText(message);
        return this;
    }
}
